<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$path = '../Mkart/';
include($path."common.php");
include($path."prod_fun.php");


$state = "Y" ;

$od_sob = trim($_POST['od_sob']) ;
$amount = $_POST['amount'];

$sql_up_od = "update kart_order set 
					order_price = '$amount' , 
					order_date = '$sdate' , 
					order_time = '$stime' 
					where order_id = '$od_sob' limit 1 
					" ;
$result_up_od = mysql_query($sql_up_od) ;

$sql_item = "select * from  order_item where order_id = '$od_sob' order by order_id" ;
$result_item = mysql_query($sql_item);
while($row_item=mysql_fetch_object($result_item)){
$item_no = $row_item->item_id;							//商品編號
$item_amount = $row_item->item_amount;						//商品購買數量

$sql_pd = "select * from  product where id = '$item_no' " ;
$result_pd = mysql_query($sql_pd);
$row_pd = mysql_fetch_object($result_pd);
$pd_count = $row_pd->pd_count; //商品庫存

$qty = $pd_count - $item_amount ;

$sql_up_item = "update product set 
					pd_count = '$qty' 
					where id = '$item_no' limit 1 
					" ;
$result_up_item = mysql_query($sql_up_item) ;
}


$checkpage = "checkout_print.php?oid=$od_sob" ;
gotopage($checkpage) ;
?>